﻿<DockPanel x:Class="BrillWpf.BrillDockPanel"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Loaded="Window_Loaded"
        >
    <DockPanel Name="BrillPanel">
        <Viewport3D Name="_viewport" ClipToBounds="True" HorizontalAlignment="Stretch">

            <!-- Defines the camera used to view the 3D object. -->
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0,0,-5" LookDirection="0,0,1" FieldOfView="60" />
            </Viewport3D.Camera>

            <!-- The ModelVisual3D children contain the 3D models -->
            <Viewport3D.Children>

                <ModelVisual3D x:Name="_light1">
                    <ModelVisual3D.Content>
                        <DirectionalLight Color="White" Direction="-0.612372,-0.5,-0.612372"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                
                <ModelVisual3D x:Name="_light2">
                    <ModelVisual3D.Content>
                        <AmbientLight Color="White"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>

                <!-- 
                <ModelVisual3D x:Name="_axisPointer">
                    <ModelVisual3D.Content>
                        <GeometryModel3D>
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D
                                     TriangleIndices="0,4,1 1,4,5 3,1,7 7,1,5 4,0,6 6,0,2 3,7,2 2,7,6 "
                                     Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
                                     Positions="-1,-1,-1 1,-1,-1 -1,1,-1 1,1,-1
                                                    -1,-1,1 1,-1,1 -1,1,1 1,1,1" />
                            </GeometryModel3D.Geometry>
                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <MaterialGroup.Children>
                                        <DiffuseMaterial Brush="CornflowerBlue"/>
                                        <SpecularMaterial Brush="AliceBlue" SpecularPower="4"/>
                                    </MaterialGroup.Children>
                                </MaterialGroup>
                            </GeometryModel3D.Material>
                            <GeometryModel3D.Transform>
                                <Transform3DGroup>
                                    <ScaleTransform3D ScaleX="0.5" ScaleY="0.5" ScaleZ="5"/>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <QuaternionRotation3D x:Name="_axisRotate"></QuaternionRotation3D>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </Transform3DGroup>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                -->
                
                <!-- 
                <ModelVisual3D x:Name="_starbox1">
                    <ModelVisual3D.Content>
                        <GeometryModel3D>
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D
                                     TriangleIndices="0,1,2 2,1,3 5,4,7 7,4,6 "
                                     TextureCoordinates="0,0 1,0 0,1 1,1 0,1 1,1, 0,0 1,0"
                                     Positions="-1,-1,-1 1,-1,-1 -1,1,-1 1,1,-1 -1,-1,1 1,-1,1 -1,1,1 1,1,1" />
                            </GeometryModel3D.Geometry>
                            <GeometryModel3D.Material>
                                <DiffuseMaterial>
                                    <DiffuseMaterial.Brush>
                                        <DrawingBrush>
                                            <DrawingBrush.Drawing>
                                                <ImageDrawing x:Name="stars1" Rect="0,0, 1,1"/>
                                            </DrawingBrush.Drawing>
                                        </DrawingBrush>
                                    </DiffuseMaterial.Brush>
                                </DiffuseMaterial>
                            </GeometryModel3D.Material>
                            <GeometryModel3D.Transform>
                                <ScaleTransform3D ScaleX="100" ScaleY="100" ScaleZ="100"/>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                <ModelVisual3D x:Name="_starbox2">
                    <ModelVisual3D.Content>
                        <GeometryModel3D>
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D
                                     TriangleIndices="0,4,1 1,4,5 3,1,7 7,1,5 4,0,6 6,0,2 3,7,2 2,7,6 "
                                     TextureCoordinates="0,0 1,0 1,0 0,0 0,1 1,1, 1,1 0,1"
                                     Positions="-1,-1,-1 1,-1,-1 -1,1,-1 1,1,-1 -1,-1,1 1,-1,1 -1,1,1 1,1,1" />
                            </GeometryModel3D.Geometry>
                            <GeometryModel3D.Material>
                                <DiffuseMaterial>
                                    <DiffuseMaterial.Brush>
                                        <DrawingBrush>
                                            <DrawingBrush.Drawing>
                                                <ImageDrawing x:Name="stars2" Rect="0,0, 1,1"/>
                                            </DrawingBrush.Drawing>
                                        </DrawingBrush>
                                    </DiffuseMaterial.Brush>
                                </DiffuseMaterial>
                            </GeometryModel3D.Material>
                            <GeometryModel3D.Transform>
                                <ScaleTransform3D ScaleX="100" ScaleY="100" ScaleZ="100"/>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                -->

                <ModelVisual3D x:Name="_model">
                    <ModelVisual3D.Content>
                        <GeometryModel3D x:Name="_geomModel">
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D x:Name="_mesh"
                                     TriangleIndices="0,1,2 3,4,5 "
                                     Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
                                     TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
                                     Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
                            </GeometryModel3D.Geometry>
                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5" Opacity="0.6">
                                                <LinearGradientBrush.GradientStops>
                                                    <GradientStop Color="Yellow" Offset="0" />
                                                    <GradientStop Color="Red" Offset="0.25" />
                                                    <GradientStop Color="Blue" Offset="0.75" />
                                                    <GradientStop Color="LimeGreen" Offset="1" />
                                                </LinearGradientBrush.GradientStops>
                                            </LinearGradientBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                    <SpecularMaterial Brush="White" SpecularPower="2"/>
                                </MaterialGroup>
                            </GeometryModel3D.Material>
                            <GeometryModel3D.Transform>
                                <Transform3DGroup>
                                    <ScaleTransform3D x:Name="_modelScale"/>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <QuaternionRotation3D x:Name="_modelRotation" Quaternion="Identity"/>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </Transform3DGroup>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                
            </Viewport3D.Children>
            
            <Viewport3D.Triggers>
                <EventTrigger x:Name="_eventTrigger" RoutedEvent="Viewport3D.Loaded">
                    <BeginStoryboard>
                        <Storyboard Name="_storyboard">
                            <QuaternionAnimation Name="_qAnimation"
                                Storyboard.TargetName="_modelRotation"
                                Storyboard.TargetProperty="Quaternion" 
                                IsAdditive="True" 
                                Duration="0:0:05" 
                                DecelerationRatio="1"
                                FillBehavior="HoldEnd"
                                                 />
                                
                        <!--
                            IsCumulative="True"
                            -->
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Viewport3D.Triggers>
            
        </Viewport3D>
    </DockPanel>
</DockPanel>
